//------------------------------------------------------------------------------
// PasCassa - a Delphi/Pascal class library for Apache Cassandra
//
// Copyright (c) 2010-2013 Jens Geyer
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//------------------------------------------------------------------------------
unit PizzaService.Constants;

interface

uses Classes, Windows, SysUtils, Math, SyncObjs;

const
  // Cassandra server and port
  PIZZA_DBSERVER_NAME = 'localhost';
  PIZZA_DBSERVER_PORT = 9160;
  PIZZA_KEYSPACE      = 'PizzaSim';

  // hardcoded number of replicas, an odd number always recommended (see QUORUM)
  // TODO: should be made configurable later on
  REPLICAS         = 1;

  // ColumnFamilies
  CF_PIZZAMENU     = 'PizzaMenu';
  CF_ORDERS        = 'Orders';
  CF_RECEIPES      = 'Receipes';
  CF_INGREDIENTS   = 'Ingredients';
  CF_CASHJOURNAL   = 'CashJournal';
  CF_COUNTERS      = 'Counters';

  ALL_COLUMNFAMILIES : array[0..5] of string
                     = ( CF_PIZZAMENU, CF_ORDERS, CF_RECEIPES,
                         CF_INGREDIENTS, CF_CASHJOURNAL, CF_COUNTERS);

  // Spalten
  COL_ID              = 'ID';
  COL_KUNDE           = 'Customer';
  COL_ARTNR           = 'ItemNr';
  COL_MENGE           = 'Quantity';
  COL_STATUS          = 'Status';
  COL_BAKER_ID        = 'Baker';
  COL_DRIVER_ID       = 'Driver';
  COL_NAME            = 'Name';
  COL_ZUTAT           = 'Ingredient';
  COL_NOTIZ           = 'Notes';
  COL_PREIS           = 'Price';
  COL_AKTIV           = 'Active';
  COL_ANZVERK         = 'DeliveryCount';
  COL_BETRAG          = 'Amount';
  COL_TEXT            = 'Text';
  COL_EINHEIT         = 'Unit';

  // Indexe
  IDX_ID              = 'ID';
  IDX_ARTNR           = 'ItemNr';
  IDX_NAME            = 'Name';
  IDX_PREIS           = 'Price';
  IDX_KUNDE           = 'Customer';
  IDX_ARTZUT          = 'PizzaIngredient';
  IDX_STATUS          = 'Status';
  IDX_BAKER           = 'Baker';
  IDX_DRIVER          = 'Driver';


  // other constants
  MAX_NAME_LINES      = 3;
  MAX_NOTES_COUNT     = 5;


type
  PArtikelData = ^TArtikelData;
  TArtikelData = record
    art : string;
    prs : Double;
    akt : Boolean;
    bez : array[0..MAX_NAME_LINES-1] of string;
    ntz : array[0..MAX_NOTES_COUNT-1] of string;
  end;

  PZutatData = ^TZutatData;
  TZutatData = record
    zut   : Integer;
    menge : Double;  // initialer Bestand
    einh  : string;
    prs   : Double;
    bez   : string;
  end;

  PRezeptData = ^TRezeptData;
  TRezeptData = record
    art   : string;
    zut   : Integer;
    menge : Double;
  end;

  TOrderStatus = ( os_Zubereitung, os_Lieferung, os_Geliefert);

const
  ARTIKEL : array[0..4] of TArtikelData
          = ( ( art:'PIZ001'; prs: 8.95; akt:TRUE; bez:('Pizza Quattro Stagioni','Chef''s recommendation',''); ntz:('Must be served hot','','Not available on mondays','','')),
              ( art:'PIZ002'; prs:10.00; akt:TRUE; bez:('Pizza Tutto','If you are about dying of hunger','')),
              ( art:'PIZ003'; prs: 6.50; akt:TRUE; bez:('Pizza Funghi','','')),
              ( art:'PIZ004'; prs: 7.50; akt:TRUE; bez:('Pizza Margherita','','')),
              ( art:'PIZ005'; prs: 8.50; akt:TRUE; bez:('Pizza Diavolo','Hot as Vesuvius in midsummer',WideChar($00BC)+'l Lambrusco included.'))
            );

  ZUTATEN  : array[0..13] of TZutatData
           = ( ( zut: 1;  menge: 100;   einh:'kg';   prs: 2.50;   bez:'Semola di grano duro'),
               ( zut: 2;  menge:  10;   einh:'kg';   prs: 6.00;   bez:'Olive green'),
               ( zut: 3;  menge:  10;   einh:'kg';   prs: 7.50;   bez:'Olive black'),
               ( zut: 4;  menge:  20;   einh:'kg';   prs:12.50;   bez:'Ham'),
               ( zut: 5;  menge:  20;   einh:'kg';   prs: 7.30;   bez:'Parmiggiano'),
               ( zut: 6;  menge:   5;   einh:'Stk';  prs: 6.00;   bez:'Peperoni'),
               ( zut: 7;  menge:  15;   einh:'kg';   prs: 8.00;   bez:'Salami'),
               ( zut: 8;  menge:  15;   einh:'kg';   prs: 6.40;   bez:'Tomatoes'),
               ( zut: 9;  menge:   5;   einh:'kg';   prs: 5.50;   bez:'Garlic'),
               ( zut:10;  menge:  30;   einh:'kg';   prs: 7.20;   bez:'White mushrooms'),
               ( zut:11;  menge:  20;   einh:'kg';   prs: 4.90;   bez:'Mozzarella'),
               ( zut:12;  menge:   1;   einh:'kg';   prs:11.00;   bez:'Oregano'),
               ( zut:13;  menge:   4;   einh:'kg';   prs: 6.60;   bez:'Basil'),
               ( zut:14;  menge:  80;   einh:'l';    prs:14.25;   bez:'Olive oil, extra vergine')
             );


  REZEPTUR : array[0..36] of TRezeptData
           = ( ( art:'PIZ001'; zut: 1; menge: 0.5),
               ( art:'PIZ001'; zut: 2; menge: 0.05),
               ( art:'PIZ001'; zut: 3; menge: 0.05),
               ( art:'PIZ001'; zut: 4; menge: 0.1),
               ( art:'PIZ001'; zut: 6; menge: 0.01),
               ( art:'PIZ001'; zut: 7; menge: 0.1),
               ( art:'PIZ001'; zut: 8; menge: 0.1),
               ( art:'PIZ001'; zut:11; menge: 0.05),
               ( art:'PIZ001'; zut:12; menge: 0.001),
               ( art:'PIZ002'; zut: 1; menge: 0.5),
               ( art:'PIZ002'; zut: 2; menge: 0.05),
               ( art:'PIZ002'; zut: 3; menge: 0.05),
               ( art:'PIZ002'; zut: 4; menge: 0.1),
               ( art:'PIZ002'; zut: 6; menge: 0.01),
               ( art:'PIZ002'; zut: 7; menge: 0.1),
               ( art:'PIZ002'; zut: 8; menge: 0.1),
               ( art:'PIZ002'; zut:11; menge: 0.05),
               ( art:'PIZ002'; zut:12; menge: 0.001),
               ( art:'PIZ003'; zut: 1; menge: 0.5),
               ( art:'PIZ003'; zut: 4; menge: 0.1),
               ( art:'PIZ003'; zut: 8; menge: 0.1),
               ( art:'PIZ003'; zut:10; menge: 0.750),
               ( art:'PIZ003'; zut:12; menge: 0.005),
               ( art:'PIZ003'; zut:13; menge: 0.010),
               ( art:'PIZ003'; zut:14; menge: 0.05),
               ( art:'PIZ004'; zut: 1; menge: 0.5),
               ( art:'PIZ004'; zut:11; menge: 0.4),
               ( art:'PIZ004'; zut:12; menge: 0.001),
               ( art:'PIZ004'; zut:13; menge: 0.030),
               ( art:'PIZ004'; zut:14; menge: 0.010),
               ( art:'PIZ005'; zut: 1; menge: 0.5),
               ( art:'PIZ005'; zut: 6; menge: 0.020),
               ( art:'PIZ005'; zut: 7; menge: 0.150),
               ( art:'PIZ005'; zut: 8; menge: 0.150),
               ( art:'PIZ005'; zut: 9; menge: 0.005),
               ( art:'PIZ005'; zut:12; menge: 0.001),
               ( art:'PIZ005'; zut:14; menge: 0.01)
             );

  ORDERSTATS : array[TOrderStatus] of string
             = ( 'ordered', 'baked', 'delivered');



implementation

// nix

end.

